<template>
  <div class="wrap">
    <el-dialog
      title="添加文本信息"
      :visible.sync="textDialog"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
    >
      <el-form label-width="120px">
        <el-form-item label="请输入文本信息">
          <el-input
            type="textarea"
            :rows="2"
            v-model="text"
            autocomplete="off"
            placeholder="请输入文本信息"
            :maxlength="650"
            show-word-limit
          ></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="close()">取消</el-button>
        <el-button type="primary" @click="confirm">确认</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "textUpload",
  props: {
    textUpload: String,
    textDialog: Boolean,
    // sendContent: Array,
  },
  data() {
    return {
      text: "",
    };
  },
  watch: {
    textDialog: {
      handler() {
        this.init();
      },
    },
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      if (this.$props.textDialog && this.$props.textUpload) {
        this.text = this.$props.textUpload;
      } else {
        this.text = "";
      }
    },
    close() {
      this.$emit("close", this.text);
      // this.text = "";
    },
    confirm() {
      if (!this.text) {
        this.$message.error("请录入文本信息");
      } else {
        this.close();
      }
    },
  },
};
</script>


<style lang='scss' scoped>
@import "../../../../styles/base.scss";
</style>
